home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / demo / flowdemo.zip / FLOSETUP.MS_ / FLOSETUP.MS
Text File  |  1994-06-24  |  10KB  |  399 lines

  1. '**************************************************************************
  2. '*                       MSSetup Toolkit Sample 2
  3. '**************************************************************************
  4.  
  5. ''$DEFINE DEBUG  ''Define for script development/debugging
  6.  
  7. '$INCLUDE 'setupapi.inc'
  8. '$INCLUDE 'msdetect.inc'
  9.  
  10. ''Dialog ID's
  11. CONST WELCOME      = 100
  12. CONST ASKQUIT      = 200
  13. CONST DESTPATH     = 300
  14. CONST EXITFAILURE  = 400
  15. CONST EXITQUIT     = 600
  16. CONST EXITSUCCESS  = 700
  17. CONST OPTIONS      = 800
  18. CONST APPHELP      = 900
  19. CONST CUSTINST     = 6200
  20. CONST TOOBIG       = 6300
  21. CONST BADPATH      = 6400
  22.  
  23. ''Bitmap ID
  24. CONST LOGO         = 1
  25.  
  26. ''File Types
  27. CONST APPFILES     = 1
  28.  
  29.  
  30. GLOBAL DEST$        ''Default destination directory.
  31. GLOBAL WINDRIVE$    ''Windows drive letter.
  32.  
  33. ''CustInst list symbol names
  34. GLOBAL APPNEEDS$    ''Option list costs per drive
  35. GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
  36. GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)
  37.  
  38. ''Dialog list symbol names
  39. GLOBAL STATUSTEXT$
  40. GLOBAL DRIVETEXT$
  41.  
  42.  
  43. DECLARE SUB AddOptFilesToCopyList (ftype%)
  44. DECLARE SUB RecalcOptFiles (ftype%)
  45. DECLARE SUB RecalcPath
  46. DECLARE SUB SetDriveStatus
  47. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  48.  
  49. ''Special function in our custom UI DLL to fix ProgMan DDE bug
  50. DECLARE SUB DoProgmanSetup(szDir$)
  51. DECLARE FUNCTION FDoProgmanSetup LIB "mscuistf.dll" (szDir$) AS INTEGER
  52.  
  53.  
  54. INIT:
  55.     CUIDLL$ = "mscuistf.dll"            ''custom user interface dll
  56.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  57.  
  58.     SetBitmap CUIDLL$, LOGO
  59.     SetTitle "FLOW Research Demo Setup"
  60.  
  61.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  62.     IF szInf$ = "" THEN
  63.         szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
  64.     END IF
  65.     ReadInfFile szInf$
  66.  
  67.     WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
  68.     DEST$ = WINDRIVE$ + ":\FLOWDEMO"
  69.  
  70.     ''CustInst list symbols
  71.     STATUSTEXT$  = "StatusItemsText"
  72.     DRIVETEXT$   = "DriveStatusText"
  73.     FOR i% = 1 TO 3 STEP 1
  74.         AddListItem STATUSTEXT$, ""
  75.     NEXT i%
  76.     FOR i% = 1 TO 7 STEP 1
  77.         AddListItem DRIVETEXT$, ""
  78.     NEXT i%
  79.     ReplaceListItem DRIVETEXT$, 7, DEST$
  80.  
  81.     ''Disk cost list symbols
  82.     APPNEEDS$   = "AppNeeds"
  83.     EXTRACOSTS$ = "ExtraCosts"
  84.     BIGLIST$    = "BigList"
  85.     FOR i% = 1 TO 3 STEP 1
  86.         AddListItem BIGLIST$, ""
  87.     NEXT i%
  88.     FOR i% = 1 TO 26 STEP 1
  89.         AddListItem EXTRACOSTS$, "0"
  90.     NEXT i%
  91.  
  92.     RecalcPath
  93.     SetDriveStatus
  94.  
  95. WELCOME:
  96.     sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
  97.     IF sz$ = "CONTINUE" THEN
  98.         UIPop 1
  99.     ELSE
  100.         GOSUB ASKQUIT
  101.         GOTO WELCOME
  102.     END IF
  103.  
  104.  
  105. CUSTINST:
  106.     sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
  107.  
  108.     IF sz$ = "CONTINUE" THEN
  109.         ''Install only if it will fit.
  110.         FOR i% = 1 TO 3 STEP 1
  111.             IF GetListItem(BIGLIST$, i%) <> "" THEN
  112.                 GOSUB TOOBIG
  113.                 GOTO CUSTINST
  114.             END IF
  115.         NEXT i%
  116.         UIPop 1
  117.         GOTO INSTALL
  118.     ELSEIF sz$ = "PATH" THEN
  119.         GOTO GETPATH
  120.     ELSEIF sz$ = "CHK1" THEN
  121.         RecalcOptFiles APPFILES
  122.         SetDriveStatus
  123.         GOTO CUSTINST
  124.     ELSEIF sz$ = "REACTIVATE" THEN
  125.         RecalcPath
  126.         SetDriveStatus
  127.         GOTO CUSTINST
  128.     ELSE
  129.         GOSUB ASKQUIT
  130.         GOTO CUSTINST
  131.     END IF
  132.  
  133.  
  134. INSTALL:
  135.     ClearCopyList
  136.     AddOptFilesToCopyList APPFILES
  137.     CreateDir DEST$, cmoNone
  138.     CopyFilesInCopyList
  139.     '' Call our custom ProgMan function in our MSCUISTF.DLL
  140.     DoProgmanSetup DEST$
  141.  
  142. QUIT:
  143.     ON ERROR GOTO ERRQUIT
  144.  
  145.     IF ERR = 0 THEN
  146.         dlg% = EXITSUCCESS
  147.     ELSEIF ERR = STFQUIT THEN
  148.         dlg% = EXITQUIT
  149.     ELSE
  150.         dlg% = EXITFAILURE
  151.     END IF
  152. QUITL1:
  153.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  154.     IF sz$ = "REACTIVATE" THEN
  155.         GOTO QUITL1
  156.     END IF
  157.     UIPop 1
  158.  
  159.     END
  160.  
  161. ERRQUIT:
  162.     i% = DoMsgBox("Setup sources were corrupted. Please call FLOW Research at 212.594.0900 to obtain a replacement disk.", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  163.     END
  164.  
  165.  
  166.  
  167. GETPATH:
  168.     SetSymbolValue "EditTextIn", DEST$
  169.     SetSymbolValue "EditFocus", "END"
  170. GETPATHL1:
  171.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  172.  
  173.     IF sz$ = "CONTINUE" THEN
  174.         olddest$ = DEST$
  175.         DEST$ = GetSymbolValue("EditTextOut")
  176.  
  177.         ''Validate new path.
  178.         IF IsDirWritable(DEST$) = 0 THEN
  179.             GOSUB BADPATH
  180.             GOTO GETPATHL1
  181.         END IF
  182.         UIPop 1
  183.  
  184.         ''Truncate display if too long.
  185.         IF LEN(DEST$) > 23 THEN
  186.             ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
  187.         ELSE
  188.             ReplaceListItem DRIVETEXT$, 7, DEST$
  189.         END IF
  190.  
  191.         ''Recalc if path changed.
  192.         IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
  193.             RecalcPath
  194.             SetDriveStatus
  195.         END IF
  196.  
  197.         olddest$ = ""
  198.         GOTO CUSTINST
  199.     ELSEIF sz$ = "REACTIVATE" THEN
  200.         RecalcPath
  201.         SetDriveStatus
  202.         GOTO GETPATHL1
  203.     ELSEIF sz$ = "EXIT" THEN
  204.         GOSUB ASKQUIT
  205.         GOTO GETPATHL1
  206.     ELSE
  207.         UIPop 1
  208.         GOTO CUSTINST
  209.     END IF
  210.  
  211.  
  212.  
  213. TOOBIG:
  214.     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  215.     IF sz$ = "REACTIVATE" THEN
  216.         RecalcPath
  217.         SetDriveStatus
  218.         GOTO TOOBIG
  219.     END IF
  220.     UIPop 1
  221.     RETURN
  222.  
  223.  
  224.  
  225. BADPATH:
  226.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  227.     IF sz$ = "REACTIVATE" THEN
  228.         RecalcPath
  229.         SetDriveStatus
  230.         GOTO BADPATH
  231.     END IF
  232.     UIPop 1
  233.     RETURN
  234.  
  235.  
  236.  
  237. ASKQUIT:
  238.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  239.  
  240.     IF sz$ = "EXIT" THEN
  241.         UIPopAll
  242.         ERROR STFQUIT
  243.     ELSEIF sz$ = "REACTIVATE" THEN
  244.         GOTO ASKQUIT
  245.     ELSE
  246.         UIPop 1
  247.     END IF
  248.     RETURN
  249.  
  250.  
  251. SUB DoProgmanSetup (szDir$) STATIC
  252.     bogus% = FDoProgmanSetup(szDir$)
  253. END SUB
  254.  
  255.  
  256. '**
  257. '** Purpose:
  258. '**     Adds the specified option files to the copy list.
  259. '** Arguments:
  260. '**     ftype%  - type of files to add, one of the following:
  261. '**             APPFILES
  262. '** Returns:
  263. '**     none.
  264. '*************************************************************************
  265. SUB AddOptFilesToCopyList (ftype%) STATIC
  266.  
  267.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  268.     IF ftype% = APPFILES THEN
  269.         AddSectionFilesToCopyList "Files", SrcDir$, DEST$
  270.     END IF
  271.     SrcDir$ = ""
  272. END SUB
  273.  
  274.  
  275. '**
  276. '** Purpose:
  277. '**     Recalculates disk space for the given option files and sets
  278. '**     the status info symbol "StatusItemsText".
  279. '** Arguments:
  280. '**     ftype% - type of files to add, one of the following:
  281. '**             APPFILES
  282. '** Returns:
  283. '**     none.
  284. '*************************************************************************
  285. SUB RecalcOptFiles (ftype%) STATIC
  286.     CursorSave% = ShowWaitCursor()
  287.     ClearCopyList
  288.     AddOptFilesToCopyList ftype%
  289.  
  290.     fExtra% = 0
  291.     IF ftype% = APPFILES THEN
  292.         ListSym$ = APPNEEDS$
  293.         ''Add extra cost to Windows drive for ini/progman, etc.
  294.         ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  295.         ReplaceListItem EXTRACOSTS$, ndrive%, "0"
  296.         fExtra% = 1
  297.     END IF
  298.  
  299.     StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
  300.  
  301.     cost& = 0
  302.     FOR i% = 1 TO 26 STEP 1
  303.         cost&  = cost& + VAL(GetListItem(ListSym$, i%))
  304.     NEXT i%
  305.     ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
  306.  
  307.     IF StillNeed& > 0 THEN
  308.         ReplaceListItem BIGLIST$, ftype%, "YES"
  309.     ELSE
  310.         ReplaceListItem BIGLIST$, ftype%, ""
  311.     END IF
  312.  
  313.     IF fExtra% THEN
  314.         ReplaceListItem EXTRACOSTS$, ndrive%, "0"
  315.     END IF
  316.     RestoreCursor CursorSave%
  317.     ListSym$ = ""
  318. END SUB
  319.  
  320.  
  321. '**
  322. '** Purpose:
  323. '**     Recalculates disk space and sets option status info according
  324. '**     to the current destination path.
  325. '** Arguments:
  326. '**     none.
  327. '** Returns:
  328. '**     none.
  329. '*************************************************************************
  330. SUB RecalcPath STATIC
  331.  
  332.     CursorSave% = ShowWaitCursor()
  333.     RecalcOptFiles APPFILES
  334.     RestoreCursor CursorSave%
  335. END SUB
  336.  
  337.  
  338. '**
  339. '** Purpose:
  340. '**     Sets drive status info according to latest disk space calcs.
  341. '** Arguments:
  342. '**     none.
  343. '** Returns:
  344. '**     none.
  345. '*************************************************************************
  346. SUB SetDriveStatus STATIC
  347.  
  348.     drive$ = MID$(DEST$, 1, 1)
  349.     ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  350.     cost& = VAL(GetListItem(APPNEEDS$, ndrive%))
  351.     free& = GetFreeSpaceForDrive(drive$)
  352.     ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
  353.     ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
  354.     ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
  355.  
  356.     IF drive$ = WINDRIVE$ THEN
  357.         ReplaceListItem DRIVETEXT$, 4, ""
  358.         ReplaceListItem DRIVETEXT$, 5, ""
  359.         ReplaceListItem DRIVETEXT$, 6, ""
  360.     ELSE
  361.         ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  362.         cost& = VAL(GetListItem(APPNEEDS$, ndrive%))
  363.         IF cost& = 0 THEN
  364.             ReplaceListItem DRIVETEXT$, 4, ""
  365.             ReplaceListItem DRIVETEXT$, 5, ""
  366.             ReplaceListItem DRIVETEXT$, 6, ""
  367.         ELSE
  368.             free& = GetFreeSpaceForDrive(WINDRIVE$)
  369.             ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
  370.             ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
  371.             ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
  372.         END IF
  373.     END IF
  374. END SUB
  375.  
  376.  
  377. '**
  378. '** Purpose:
  379. '**     Appends a file name to the end of a directory path,
  380. '**     inserting a backslash character as needed.
  381. '** Arguments:
  382. '**     szDir$  - full directory path (with optional ending "\")
  383. '**     szFile$ - filename to append to directory
  384. '** Returns:
  385. '**     Resulting fully qualified path name.
  386. '*************************************************************************
  387. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  388.     IF szDir$ = "" THEN
  389.         MakePath = szFile$
  390.     ELSEIF szFile$ = "" THEN
  391.         MakePath = szDir$
  392.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  393.         MakePath = szDir$ + szFile$
  394.     ELSE
  395.         MakePath = szDir$ + "\" + szFile$
  396.     END IF
  397. END FUNCTION
  398.  
  399.